= include_gon
%ul.top-nav
  %li
    = "开始时间："
    %span#start_time
  %li
    = "剩余时间（分钟）："
    %span#left_time
  %li= "总共#{@my_exam.my_questions.count}道题"
  %li= "已作答#{@my_exam.current_question_index}道题"
:javascript
  var start_date = new Date(gon.start_time_in_sec * 1000)
  var left_seconds = gon.left_seconds
  
  $("#start_time").text(format_date(start_date))
  var interval = setInterval(function(){
    left_seconds --;
    var m = Math.floor(left_seconds/ 60);
    var s = left_seconds%60;
    $("#left_time").text(m.toString()+":"+s.toString());
    if(left_seconds <= 0){
    exam_timeout();
    clearInterval(interval);
    }
  },1000);

  //window.setTimeout("exam_timeout();", left_seconds * 1000)

  function format_date (date) {
    return date.format("yyyy-MM-dd hh:mm:ss");
  }

  function format_float (f) {
    return Math.round( f * 10 )/ 10
  }

  function exam_timeout () {
    alert("时间到！测试结束！");
    window.location.reload();
  }
